let express = require("express");
let app = express();

// 设置跨域，解决跨域问题
app.use(function(req, res, next) {
    res.header("Access-Control-Allow-Origin", '*');
    res.header("Access-Control-Allow-Headers", 'Content-Type,Content-Length,Authorization,Accept,X-Requested-With,yourHeaderFeild');
    res.header('Access-Control-Allow-Methods', 'PUT,POST,GET,DELETE,OPTIONS');
    next();
});

let chartAppearance = require("./router/deviceAppearance");
let chartDetails = require("./router/deviceDetails");
let chartHistory = require("./router/deviceHistory");
let chartRealtime = require("./router/deviceRealtime");
let chartPercentage = require("./router/powerPercentage");

app.use("/deviceAppearance", chartAppearance);
app.use("/deviceDetails", chartDetails);
app.use("/deviceHistory", chartHistory);
app.use("/deviceRealtime", chartRealtime);
app.use("/powerPercentage", chartPercentage);

app.listen(8888, () => {
    console.log("Server running on http://localhost:8888");
});